#ifndef USER_H
#define USER_H

#include <QString>
#include <QtSql/QSqlDatabase>
#include <QSqlQuery>
#include <QSqlQueryModel>
#include <QDebug>
#include "article.h"
#include "user.h"

class User {
public:
    enum {CONSUMER = 0, COURIER, ADMIN};
    User();
    bool signIn();
    QString logIn();    // 返回登录用户名
    void editPassword();
    void setInitInfo(QString name, QString pass); // 用户名密码
    double charge(double money);  // 修改余额, 返回现余额
protected:
    QString username;
    QString password;
    QString name;
    QSqlDatabase db;
    QSqlQueryModel model;
    double balance;
    int type;
};

class Consumer : public User {
public:
    Consumer();
    Consumer(QString username);
    bool pay(double money);

private:
    QString phoneNum;
    QString address;
};

class Admin : public User {
public:
    Admin();
    Admin(QString username);
private:
};


class Courier : public User {
public:
    Courier();
    Courier(QString username);
    void editInfo(QString name, QString phone);
private:
    QString PhoneNum;
};

#endif // USER_H
